<div class="layui-container fly-marginTop fly-user-main">
  {include file='common/menu'/}
  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>


  <div class="fly-panel fly-panel-user" pad20>
    <!--
      <div class="fly-msg" style="margin-top: 15px;">
        您的邮箱尚未验证，这比较影响您的帐号安全，<a href="activate.html">立即去激活？</a>
      </div>
      -->
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li data-type="mine-jie" lay-id="index" class="layui-this">我发的帖（<span>{$postcount}</span>）</li>
        <li data-type="collection" lay-id="collection">我收藏的帖（<span>{$collectcount}</span>）</li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <ul class="mine-view jie-row">
            {foreach $PostList as $item}
            <li>
              <span class="fly-jing">{$item.state_text}</span>
              <a class="jie-title" href="{:url('/home/post/info',['postid' => $item['id']])}"
                target="_blank">{$item.title}</a>
              <i>{$item.createtime|date="Y-m-d H:i"}</i>
              <a class="mine-edit" href="{:url('/home/post/add',['postid' => $item['id']])}">编辑</a>
              <em>{$item->visit_count}阅/{$item->comment_count}答</em>
            </li>
            {/foreach}
          </ul>
          <div style="text-align: center">
            {$PostList|raw}
          </div>
          
        </div>
        <div class="layui-tab-item">
          <ul class="mine-view jie-row">
            {foreach $CollectList as $item}
            <li>
              <a class="jie-title" href="{:url('/home/post/info',['postid' => $item['postid']])}"
                target="_blank">{$item.post.title}</a>
              <i>{$item.createtime|date="Y-m-d H:i"}</i>
              <a class="mine-edit jie-admin" data-collectid="{$item['id']}" id="collect">取消收藏</a>
            </li>
            {/foreach}
          </ul>
          <div style="text-align: center">
            {$CollectList|raw}
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  layui.use(['layer'], function () {
    var $ = layui.jquery,
      layer = layui.layer;
    //取消收藏
    $('#collect').click(function () {
      var collectid = $(this).data('collectid')
      $.ajax({
        type: "post",
        url: `{:url('/home/User/mypost')}`,
        data: {
          collectid
        },
        dataType: "json",
        success: function (res) {
          if (res.code === 1) {
            layer.msg(res.msg, {
              icon: 1,
              time: 600
            }, function () {
              location.reload()
            })
          } else {
            layer.msg(res.msg,{
              icon: 2,
              time: 600
            })
          }
        }
      });
    })
  })
</script>